home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / regnpckg.sit / Region XCMD / stack.txt < prev   
Text File  |  1990-12-10  |  7KB  |  247 lines

  1. -- stack: in
  2. -- format: 10 (HyperCard 2)
  3. -- flags: 0x9000 (can't modify)
  4. -- protect password hash: 0
  5. -- maximum user level: 5 (scripting)
  6. -- window: Rect(x1=32, y1=66, x2=448, y2=306)
  7. -- screen: Rect(x1=0, y1=0, x2=512, y2=342)
  8. -- card dimensions: w=416 h=240
  9. -- scroll: x=0 y=0
  10. -- background count: 1
  11. -- first background id: 2620
  12. -- card count: 1
  13. -- first card id: 3066
  14. -- list block id: 3828
  15. -- print block id: 0
  16. -- font table block id: 3515
  17. -- style table block id: 3080
  18. -- free block count: 1
  19. -- free size: 5792 bytes
  20. -- total size: 16384 bytes
  21. -- stack block size: 6656 bytes
  22. -- created by hypercard version: 0x02008000
  23. -- compacted by hypercard version: 0x02008000
  24. -- modified by hypercard version: 0x02008000
  25. -- opened by hypercard version: 0x02008000
  26. -- patterns[0]: 0x0000000000000000
  27. -- patterns[1]: 0x8000000008000000
  28. -- patterns[2]: 0x8800220088002200
  29. -- patterns[3]: 0x8888222288882222
  30. -- patterns[4]: 0x88AA22AA88AA22AA
  31. -- patterns[5]: 0xCCAA33AACCAA33AA
  32. -- patterns[6]: 0xEEAABBAAEEAABBAA
  33. -- patterns[7]: 0xEEBBBBEEEEBBBBEE
  34. -- patterns[8]: 0xFFBBFFEEFFBBFFEE
  35. -- patterns[9]: 0xFFBBFFFFFFBBFFFF
  36. -- patterns[10]: 0x8010022001084004
  37. -- patterns[11]: 0xFFFFFFFFFFFFFFFF
  38. -- patterns[12]: 0x8822882288228822
  39. -- patterns[13]: 0x1122448811224488
  40. -- patterns[14]: 0xC4800C6843023026
  41. -- patterns[15]: 0xB130031BD8C00C8D
  42. -- patterns[16]: 0xAA00AA00AA00AA00
  43. -- patterns[17]: 0x8822552288225522
  44. -- patterns[18]: 0x8855225588552255
  45. -- patterns[19]: 0x77DD77DD77DD77DD
  46. -- patterns[20]: 0x8000000000000000
  47. -- patterns[21]: 0xAA55AA55AA55AA55
  48. -- patterns[22]: 0x038448300C020101
  49. -- patterns[23]: 0x8244394482010101
  50. -- patterns[24]: 0x8814224188412214
  51. -- patterns[25]: 0x8080413E080814E3
  52. -- patterns[26]: 0x22048C7422179810
  53. -- patterns[27]: 0xBE808808EB088880
  54. -- patterns[28]: 0x25C8328964244C92
  55. -- patterns[29]: 0xA29C41BE2AC914EB
  56. -- patterns[30]: 0x40A00000040A0000
  57. -- patterns[31]: 0x8040200002040800
  58. -- patterns[32]: 0xAA00800088008000
  59. -- patterns[33]: 0xFF80808080808080
  60. -- patterns[34]: 0x081C22C180010204
  61. -- patterns[35]: 0xFF808080FF080808
  62. -- patterns[36]: 0xF87422478F172271
  63. -- patterns[37]: 0xBF00BFBFB0B0B0B0
  64. -- patterns[38]: 0xFF7FBE5DA2418000
  65. -- patterns[39]: 0xFAF5FAF5A050A050
  66. -- checksum: 0x5F8E4EF6
  67. ----- HyperTalk script -----
  68. -- Region XCMD support scripts
  69. -- ┬⌐ 1990, Nigel Perry. Free for personal use.
  70. -- May not be used for commercial, profit-making or in ShareWare
  71. -- without permission.
  72.  
  73. -- add menu item for creation
  74. -- make sure BMTR trap exists
  75. on setupRegions
  76.   install_BMTR
  77.   if "Objects" is in the menus then
  78.     if "New RegionΓǪ" is not in menu "Objects" then
  79.       put "New RegionΓǪ" before menuItem "New Button" of menu "Objects" with menuMessage "Region new"
  80.     end if
  81.   end if
  82.   if "Edit" is in the menus then
  83.     if "RegionsΓǪ" is not in menu "Edit" then
  84.       put "RegionsΓǪ" after menuItem "Icon..." of menu "Edit" with menuMessage "Region edit"
  85.     end if
  86.   end if
  87. end setupRegions
  88.  
  89. -- remove menu item
  90. on cleanupRegions
  91.   if "Objects" is in the menus then
  92.     if "New RegionΓǪ" is in menu "Objects" then
  93.       delete menuItem "New RegionΓǪ" of menu "Objects"
  94.     end if
  95.   end if
  96.   if "Edit" is in the menus then
  97.     if "RegionsΓǪ" is in menu "Edit" then
  98.       delete menuItem "RegionsΓǪ" of menu "Edit"
  99.     end if
  100.   end if
  101. end cleanupRegions
  102.  
  103. -- support clip to PICT conversion
  104. on doMenu cmd
  105.   if cmd is "Paste Picture" and the optionKey is down
  106.   then
  107.   get the long name of this stack
  108.   put word 2 of it into path
  109.   delete char 1 of path
  110.   delete last char of path
  111.   Region pastePICT,path
  112. else
  113.   pass doMenu
  114. end if
  115. end doMenu
  116.  
  117. -- support edit mode selection
  118. on choose ignore,tool
  119.   if tool Γëñ 3 and the optionKey is down
  120.   then
  121.   Region edit,tool
  122. else
  123.   Region normal
  124. end if
  125. pass choose
  126. end choose
  127.  
  128. -- toggle palette just like the Tools one
  129. on keyDown key
  130.   if key is tab and the optionKey is down then
  131.     if "Region Palette" is in the windows then
  132.       set the visible of window "Region Palette" to not the visible of window "Region Palette"
  133.     end if
  134.   end if
  135.   pass keyDown
  136. end keyDown
  137.  
  138. -- create a script to create a Region
  139. -- designed to be called by Region XCMD only
  140. function _dump_Region where
  141. global targetRegion
  142. global _region_handler
  143.  
  144. set cursor to busy
  145. put return & "on" && _region_handler & return into handler
  146. put the picture of window targetRegion into pict
  147. put the region of window targetRegion into region
  148. put the rect of window targetRegion into rect
  149. put "Region" && targetRegion & "," & quote & rect & quote & "," & quote & pict & quote & "," & quote & region & quote & return after handler
  150. set cursor to busy
  151. put the mouseDown of window targetRegion into hand
  152. if hand is not empty then
  153.   put "set the mouseDown of window" && targetRegion && "to" && _literal(hand) & return after handler
  154. end if
  155. set cursor to busy
  156. put the mouseWithin of window targetRegion into hand
  157. if hand is not empty then
  158.   put "set the mouseWithin of window" && targetRegion && "to" && _literal(hand) & return after handler
  159. end if
  160. set cursor to busy
  161. put the mouseStillDown of window targetRegion into hand
  162. if hand is not empty then
  163.   put "set the mouseStillDown of window" && targetRegion && "to" && _literal(hand) & return after handler
  164. end if
  165. set cursor to busy
  166. put the mouseUp of window targetRegion into hand
  167. if hand is not empty then
  168.   put "set the mouseUp of window" && targetRegion && "to" && _literal(hand) & return after handler
  169. end if
  170. set cursor to busy
  171. put the idle of window targetRegion into hand
  172. if hand is not empty then
  173.   put "set the idle of window" && targetRegion && "to" && _literal(hand) & return after handler
  174. end if
  175. set cursor to busy
  176. put the idleTime of window targetRegion into val
  177. if val Γëá 0 then
  178.   put "set the idleTime of window" && targetRegion && "to" && val & return after handler
  179. end if
  180. set cursor to busy
  181. if the autoHilite of window targetRegion then
  182.   put "set the autoHilite of window" && targetRegion && "to true" & return after handler
  183. end if
  184. put "end" && _region_handler & return after handler
  185.  
  186. put empty into _region_handler
  187.  
  188. if where = 0 then -- card
  189.   put the script of this cd into x
  190.   set cursor to busy
  191.   set the script of this cd to (x & handler)
  192. else if where = 1 then -- bg
  193.   put the script of this bg into x
  194.   set cursor to busy
  195.   set the script of this bg to (x & handler)
  196. else if where = 2 then -- stk
  197.   put the script of this stack into x
  198.   set cursor to busy
  199.   set the script of this stack to (x & handler)
  200. else -- clip
  201.   return handler
  202. end if
  203.  
  204. return empty
  205.  
  206. end _dump_Region
  207.  
  208. -- convert text into a literal string
  209. function _literal text
  210. put quote into ans
  211.  
  212. repeat with i = 1 to the number of chars in text
  213.   put char i of text into c
  214.   if c = quote then
  215.     put quote && "& quote &" && quote after ans
  216.   else if c = return then
  217.     put quote && "& return & ┬¼" & return & quote after ans
  218.   else
  219.     put c after ans
  220.   end if
  221.   set cursor to busy
  222. end repeat
  223.  
  224. put quote after ans
  225. return ans
  226. end _literal
  227.  
  228. function _edit_Region_Script
  229. global targetRegion
  230. global _region_handler
  231.  
  232. return EditScript("the" && _region_handler && "of window" && targetRegion, _region_handler && "of region" && targetRegion, "set the" && _region_handler && "of window" && targetRegion && "to editResult")
  233. end _edit_Region_Script
  234.  
  235. on testEdit
  236.   global targetRegion
  237.   global _region_handler
  238.  
  239.   ask "Region?"
  240.   put it into targetRegion
  241.   ask "Handler?"
  242.   put it into _region_handler
  243.   if not _edit_Region_Script() then
  244.     answer "Failed"
  245.   end if
  246. end testEdit
  247.